﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PurchaseIntoShow.aspx.cs" Inherits="FJERP.PurchaseIntoShow" %>

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>供应商列表</title>
</head>
<body>
    <form runat="server">
       <div class="page-container">


            <div>
                采购单号
                        <asp:TextBox ID="TextBox2" runat="server" class="input-text" style="width: 250px"></asp:TextBox>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        供应商
                        
                            <asp:DropDownList ID="DropDownList1" runat="server" class="input-text" style="width: 250px"></asp:DropDownList>
                <%--供应商--%>
                <br />
                <br />
                &nbsp;&nbsp;&nbsp;
                        仓库&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        
                            <asp:DropDownList ID="DropDownList3" runat="server" class="input-text" style="width: 250px"></asp:DropDownList>
                <%--仓库--%>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        经办人
                        
                            <asp:DropDownList ID="DropDownList2" runat="server" class="input-text" style="width: 250px"></asp:DropDownList>
                <%--经办人--%>
                <br />
                <br />
                <input type="text" id="Product_Modelspe" class="input-text" style="width: 250px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input id="Button1" type="button" value="根据商品规格搜索" onclick="fun()" style="border-radius: 35px,35px; width: 250px"  class="input-text"/>

            </div>
            <table class="table table-border table-bordered table-bg table-hover table-sort" id="psser">
                <thead>
                    <tr class="text-c">
                        <th>商品名称</th>
                        <th>规格型号</th>
                        <th>进价</th>
                        <th>商品类别</th>
                        <th>生产厂商</th>
                        <th>数量</th>
                        <th>总金额</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            小计：<span id="aa"></span><br />

            <input type="button" onclick="add()" value="生成采购单" />

        </div>
      <script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="js/H-ui.js"></script>
    <script type="text/javascript" src="js/H-ui.admin.js"></script>
        <script type="text/javascript">

            function fun() {
               
                var ss = $("#Product_Modelspe").val();

                $.ajax({
                    type: "post",
                    url: "Handler/Purcachase.ashx",
                    data: {
                        action: "IntoSearch",
                        Product_Modelspe: ss,
                    },
                    success: function (data1) {
                        var data = eval(data1);
                        for (var i in data) {
                            var pp = "<tr class='text-c' id='P" + data[i].Product_Id + "' ><td><input type='hidden' value='" + data[i].Product_Id + "' name='Product_Id' />" + data[i].Product_Name + "</td><td>" + data[i].Product_Modelspe + "</td><td  id='price" + data[i].Product_Id + "'>" + data[i].Product_Price + "</td><td>" + data[i].Product_Type_Name + "</td><td>" + data[i].Product_frim + "</td><td><input name='num' id='num" + data[i].Product_Id + "' type='text' class='input-text' style='width:200px;' onchange='fun1(" + data[i].Product_Id + ")' /></td><td><span name='SumMoney' id='SumMoney" + data[i].Product_Id + "'>0</span></td></tr>";
                            if ($("#P" + data[i].Product_Id + "").length > 0) {
                                alert("已存在不能再添加！");
                                return;
                            }
                            else {
                                $(".table tbody").append(pp);
                            }

                        }
                    }
                })


            }


            function fun1(id) {
                var num = $("#num" + id + "").val();
                var price = $("#price" + id + "").html();
                var sum = num * price;
                $("#SumMoney" + id + "").html(sum);
                var sum=0;
                $("[name='SumMoney']").each(function () {
                    
                    sum += parseInt($(this).html());
                    
                })
                $("#aa").text(sum);

            }
            function add() {
                var Product_Id = new Array();
                var i = -1;
                $("[name='Product_Id']").each(function () {
                    i++;
                    Product_Id[i] = $(this).val();

                })
                var PurchaseMate_Num = new Array();
                var p = -1;
                $("[name='num']").each(function () {
                    p++;
                    PurchaseMate_Num[p] = $(this).val();
                })
                var PurchaseMate_Price = new Array();
                var r = -1;
                $("[name='SumMoney']").each(function () {
                    r++;
                    PurchaseMate_Price[r] = $(this).html();
                })
                //字符拼接xml
                var xml = "<mm>";
                for (var i = 0; i < Product_Id.length; i++) {
                    xml += "<xx Product_Id='" + Product_Id[i] + "' PurchaseMate_Num='" + PurchaseMate_Num[i] + "' PurchaseMate_Price='" + PurchaseMate_Price[i] + "' />";
                }
                xml += "</mm>";
                var encodexml = encodeURIComponent(xml);// 对xml进行编码
                alert(encodexml);
                $.ajax({
                    type: "post",
                    url: "Handler/Purcachase.ashx",
                    data: {
                        action: "IntoList",
                        Supplier_Id: $("#DropDownList1").val(),
                        WareHose_Id: $("#DropDownList3").val(),
                        Employee_Id: $("#DropDownList2").val(),
                        SumMoney:$("#aa").text(),
                        xml: encodexml
                    },
                    success: function (data) {
                        if (data > 0) {
                            alert("生成采购单成功");parent.location.reload();parent.layer.close(parent.layer.getFrameIndex(window.name));
                            ;
                        }
                    },
                    error: function () {
                        alert("警告！警告！警告！警告！警告！警告！警告！"); parent.location.reload(); parent.layer.close(parent.layer.getFrameIndex(window.name));

                    }
                })

            }
        </script></form>

<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
    {"appName":"Firefox","requestId":"f569eb7d4df945928a4bedc9cc45903d"}
</script>
<script type="text/javascript" src="http://localhost:26516/b63ee82e3f23478e87ae72d60666dcd2/browserLink" async="async"></script>
<!-- End Browser Link -->

</body>
</html>
